package moga.logic;

import java.util.Vector;


public class TestFunctions {
	Class<? extends TestFunctions> clase  = this.getClass();
	double interval=0.01;
	int m=10;
	
	
	public Vector<double[]> function1() { 
		System.out.println(this.clase+" function1()  Iniciado....");
		
		Vector<double[]> points = new Vector<double[]>();
		double point[];
		double yValue=0;
		double xValue=0;
		double dblG=0;
		double dblH=0;
		this.m= 30;
		
		for(double i=0; i<=1; i=i+this.interval){
			point = new double[2];
			xValue = i;
			//dblG= 1 + (9 * this.sumFunction123(0, m));
			dblG= 1 ;
			dblH = 1- Math.sqrt(xValue/dblG);
			yValue = dblG * dblH; 
			point[0]= xValue;
			point[1]= yValue;
			
			points.add(point);
		}
		
		System.out.println(this.clase+" function1()  Terminado....");
		return points;
	}
	
	public Vector<double[]> function2() {
		System.out.println(this.clase+" function2()  Iniciado....");
		Vector<double[]> points = new Vector<double[]>();
		double point[];
		double yValue=0;
		double xValue=0;
		double dblG=0;
		double dblH=0;
		this.m =30;
		
		for(double i=0; i<=1; i=i+this.interval){
			point = new double[2];
			xValue = i;
			//dblG= 1 + (9 * this.sumFunction123(0, m));
			dblG = 1 ;
			dblH = 1- Math.pow(xValue/dblG, 2);
			yValue = dblG * dblH;
			
			point[0]= xValue;
			point[1]= yValue;
			points.add(point);
		}
		
		//this.chartPanel.update(this.chartPanel.getGraphics());
		System.out.println(this.clase+" function2()  Terminado....");
		return points;
	}

	public Vector<double[]> function3() { 
		System.out.println(this.clase+" function3()  Iniciado....");
		
		Vector<double[]> points = new Vector<double[]>();
		double point[];
		double yValue=0;
		double xValue=0;
		double dblG=0;
		double dblH=0; 
		this.m=30;
		
		for(double i=0; i<=1; i=i+this.interval){
			point = new double[2];
			xValue = i;
			//dblG= 1 + (9 * this.sumFunction123(0, m));
			dblG= 1;
			dblH = 1- Math.sqrt(xValue/dblG)-(xValue/dblG)* Math.sin(10 * Math.PI * xValue);
			yValue = dblG * dblH;
			
			point[0]= xValue;
			point[1]= yValue;
			points.add(point);
		}
		
		System.out.println(this.clase+" function3()  Terminado....");
		return points;
	}
	
	
	public double sumFunction123(double x, int m){
		double dblRet=0;
				
		for(int i=2; i<=m; i++){
			dblRet=dblRet +(x/(m-1));
		}
		return dblRet;
	}

	public Vector<double[]> function4() {
		System.out.println(this.clase+" function4()  Iniciado....");
		
		Vector<double[]> points = new Vector<double[]>();
		double point[];
		double yValue=0;
		double xValue=0;
		double dblG=0;
		double dblH=0;
		this.m=10;
		
		for(double i=0; i<=1; i=i+this.interval){
			point = new double[2];
			xValue = i;
			//dblG= 1 +(10 * (m - 1))+ this.sumFunction4(0, m);
			dblG= 1 ;
			dblH= 1 - Math.sqrt(xValue/dblG);
			yValue = dblG * dblH;
			
			point[0]= xValue;
			point[1]= yValue;
			points.add(point);
		}
		
		
		System.out.println(this.clase+" function4()  Terminado....");
		return points;
	}
	
	public double sumFunction4(double x, int m){
		double dblRet=0;
				
		for(int i=2; i<=m; i++){
			dblRet=dblRet + (Math.pow(x, 2) - (10 * Math.cos(4 * Math.PI * x)));
		}
		return dblRet;
	}
	
	public Vector<double[]> function5() {
		System.out.println(this.clase+" function5()  Iniciado....");
		
		Vector<double[]> points = new Vector<double[]>();
		double point[];
		double yValue=0;
		double xValue=0;
		double dblG=0;
		double dblH=0;
		this.m=11;
		int x1[] = new int[31];
		
		for(int j=0; j<31; j++){
			x1[j]= j;
		}	
		
		
		for(int i=0; i< 31; i++){
			point = new double[2];
			
			xValue=1 + x1[i];
			dblG = 10;
			dblH = 1 / xValue;
			yValue=dblG * dblH;
			
			point[0]= xValue;
			point[1]= yValue;
			points.add(point);
			System.out.println("Values: "+xValue+" y "+yValue);
		}
		System.out.println(this.clase+" function5()  Terminado....");
		return points;
	}
	
	public int u(int[] arrOnes){
		int intRet=0;
		for (int i=0; i<arrOnes.length; i++){
			intRet+= arrOnes[i];
		}
		return intRet;
	}

	public Vector<double[]> function6() {
		System.out.println(this.clase+" function6()  Iniciado....");
		Vector<double[]> points = new Vector<double[]>();
		double point[];
		double yValue=0;
		double xValue=0;
		double dblG=0;
		this.m =10;
		
		for(double i=0; i<=1; i=i+this.interval){
			point = new double[2];
			xValue = 1 - Math.exp(-4 * i) * Math.pow( Math.sin(6 * Math.PI * i) , 6);
			//dblG= 1 + ( 9 * Math.pow(( this.sumFunction6(0,m) / (m-1) ) , 0.25 ) );
			dblG= 1;
			yValue = 1 - Math.pow( (xValue / dblG ) , 2 );
			
			point[0]= xValue;
			point[1]= yValue;
			points.add(point);
		}
		
		System.out.println(this.clase+" function6()  Terminado....");
		return points;
	}
	
	public double sumFunction6(double x, int m){
		double dblRet=0;
				
		for(int i=2; i<=m; i++){
			dblRet=dblRet + x;
		}
		return dblRet;
	}
	
	
	public void setInterval(double dblInterval){
		this.interval = dblInterval;
	}
	
	public void setM(int m){
		this.m = m;
	}

}
